<?php

namespace Chaosyeo\SolarEngine\Event;

class ClickAdProperties extends Properties
{
    // 广告类型枚举
    const AD_TYPE_REWARD_VIDEO    = 1;    // 激励视频
    const AD_TYPE_SPLASH          = 2;    // 开屏
    const AD_TYPE_INTERSTITIAL    = 3;    // 插屏
    const AD_TYPE_FULL_VIDEO      = 4;    // 全屏视频
    const AD_TYPE_BANNER          = 5;    // Banner
    const AD_TYPE_FEED            = 6;    // 信息流
    const AD_TYPE_SHORT_VIDEO     = 7;    // 短视频信息流
    const AD_TYPE_LARGE_BANNER    = 8;    // 大横幅
    const AD_TYPE_VIDEO_PATCH     = 9;    // 视频贴片
    const AD_TYPE_OTHER           = 10;   // 其它

    // 变现平台枚举
    const AD_PLATFORM_CSJ         = 'csj';        // 穿山甲国内版
    const AD_PLATFORM_PANGLE      = 'pangle';     // 穿山甲国际版
    const AD_PLATFORM_TENCENT     = 'tencent';    // 腾讯优量汇
    const AD_PLATFORM_BAIDU       = 'baidu';      // 百度百青藤
    const AD_PLATFORM_KUAISHOU    = 'kuaishou';   // 快手
    const AD_PLATFORM_OPPO        = 'oppo';       // OPPO
    const AD_PLATFORM_VIVO        = 'vivo';       // vivo
    const AD_PLATFORM_MI          = 'mi';         // 小米
    const AD_PLATFORM_HUAWEI      = 'huawei';     // 华为
    const AD_PLATFORM_APPLOVIN    = 'applovin';   // Applovin
    const AD_PLATFORM_SIGMOB      = 'sigmob';     // Sigmob
    const AD_PLATFORM_MINTEGRAL   = 'mintegral';  // Mintegral
    const AD_PLATFORM_ONEWAY      = 'oneway';     // OneWay
    const AD_PLATFORM_VUNGLE      = 'vungle';     // Vungle
    const AD_PLATFORM_FACEBOOK    = 'facebook';   // Facebook
    const AD_PLATFORM_ADMOB       = 'admob';      // AdMob
    const AD_PLATFORM_UNITY       = 'unity';      // UnityAds
    const AD_PLATFORM_IS          = 'is';         // IronSource
    const AD_PLATFORM_ADTIMING    = 'adtiming';   // AdTiming
    const AD_PLATFORM_KLEIN       = 'klein';      // 游可赢
    const AD_PLATFORM_FYBER       = 'fyber';      // Fyber
    const AD_PLATFORM_CHARTBOOST  = 'chartboost'; // Chartboost
    const AD_PLATFORM_ADCOLONY    = 'adcolony';   // Adcolony
    const AD_PLATFORM_INMOBI      = 'inmobi';     // Inmobi

    // 聚合平台枚举
    const MEDIATION_MAX          = 'max';
    const MEDIATION_IRONSOURCE   = 'ironsource';
    const MEDIATION_ADMOB        = 'admob';
    const MEDIATION_HYPERBID     = 'hyperbid';
    const MEDIATION_TOPON        = 'topon';
    const MEDIATION_CAS          = 'cas';
    const MEDIATION_TRADPLUS     = 'tradplus';
    const MEDIATION_TOBID        = 'tobid';
    const MEDIATION_GROMORE      = 'gromore';
    const MEDIATION_CUSTOM       = 'custom';

    protected $adPlatform;         // 变现平台
    protected $mediationPlatform;  // 聚合平台标识
    protected $adId;               // 变现广告位 ID
    protected $adType;             // 广告类型

    /**
     * @param string $adPlatform 变现平台（必传）
     * @param string $mediationPlatform 聚合平台标识（必传）
     * @param string $adId 变现广告位 ID（必传）
     * @param int $adType 广告类型（必传）
     */
    public function __construct(int $platform, string $adPlatform, string $mediationPlatform, string $adId, int $adType, array $params = [], array $customParams = [])
    {
        if (empty($adPlatform) || !in_array($adPlatform, [
            self::AD_PLATFORM_CSJ,        self::AD_PLATFORM_PANGLE,     self::AD_PLATFORM_TENCENT,
            self::AD_PLATFORM_BAIDU,      self::AD_PLATFORM_KUAISHOU,   self::AD_PLATFORM_OPPO,
            self::AD_PLATFORM_VIVO,       self::AD_PLATFORM_MI,         self::AD_PLATFORM_HUAWEI,
            self::AD_PLATFORM_APPLOVIN,   self::AD_PLATFORM_SIGMOB,     self::AD_PLATFORM_MINTEGRAL,
            self::AD_PLATFORM_ONEWAY,     self::AD_PLATFORM_VUNGLE,     self::AD_PLATFORM_FACEBOOK,
            self::AD_PLATFORM_ADMOB,      self::AD_PLATFORM_UNITY,      self::AD_PLATFORM_IS,
            self::AD_PLATFORM_ADTIMING,   self::AD_PLATFORM_KLEIN,      self::AD_PLATFORM_FYBER,
            self::AD_PLATFORM_CHARTBOOST, self::AD_PLATFORM_ADCOLONY,   self::AD_PLATFORM_INMOBI
        ])) {
            throw new \InvalidArgumentException('Invalid ad platform');
        }

        if (empty($mediationPlatform) || !in_array($mediationPlatform, [
            self::MEDIATION_MAX,        self::MEDIATION_IRONSOURCE, self::MEDIATION_ADMOB,
            self::MEDIATION_HYPERBID,   self::MEDIATION_TOPON,      self::MEDIATION_CAS,
            self::MEDIATION_TRADPLUS,   self::MEDIATION_TOBID,      self::MEDIATION_GROMORE,
            self::MEDIATION_CUSTOM
        ])) {
            throw new \InvalidArgumentException('Invalid mediation platform');
        }

        if (empty($adId)) {
            throw new \InvalidArgumentException('Ad ID is required');
        }

        if (!in_array($adType, [
            self::AD_TYPE_REWARD_VIDEO, self::AD_TYPE_SPLASH,       self::AD_TYPE_INTERSTITIAL,
            self::AD_TYPE_FULL_VIDEO,   self::AD_TYPE_BANNER,       self::AD_TYPE_FEED,
            self::AD_TYPE_SHORT_VIDEO,  self::AD_TYPE_LARGE_BANNER, self::AD_TYPE_VIDEO_PATCH,
            self::AD_TYPE_OTHER
        ])) {
            throw new \InvalidArgumentException('Invalid ad type');
        }

        $this->adPlatform        = $adPlatform;
        $this->mediationPlatform = $mediationPlatform;
        $this->adId              = $adId;
        $this->adType            = $adType;

        parent::__construct($platform, $params, $customParams);
    }
}